# -*- coding: utf-8 -*-

__author__ = 'Fonny'


def pyahk_test():
    """
    ahk_dll 操作演示
    
    参考: https://pyahk.readthedocs.io/en/latest/
    
    :return: 
    :rtype: 
    """

    import ahk

    # 运行外部ahk脚本,并接收返回值
    print '***\n本脚本仅适用于 ahk_dll_ansi & python 2.7 x86, ' \
          'ahk脚本文件必须设为 ansi 编码.\n***\n'

    ahk.start('py_test.ahk')
    ahk.ready()
    # 必须进行转码才可以在控制台正确显示
    ahkReStr = str(ahk.get('gv_re')).decode('gbk')
    # 类型为 unicode
    print 'ahkReStr:', type(ahkReStr)
    print 'ahkReStr:', ahkReStr

    # 销毁ahk线程
    ahk.terminate(2)
    print "\nAHK Tread terminated."
    return ''


def main():
    pyahk_test()


if __name__ == '__main__':
    main()
